<?php
namespace app\app\process;

use app\common\process\Base as ParentProcess;

class Login extends ParentProcess {
	//app用户密码登录
	public function login() {
		$post = loader('app')->loadAny('request', 'Login')->index();
		$validate = loader('app')->loadValidate('Login');
		if(!$validate->scene('login')->check($post)) {
			$this->error($validate->getError());	
		}
		$storage = loader('app')->loadAny('storage', 'Login');
		unset($post['password']);
		$token = $storage->get_token($post);
        $user = $storage->getCurrentUser($token);
        $user['token'] = $token;
        $user['push_clientid'] = $post['push_clientid'];
        trigger('after_login', [$user, $post], 'app');
        $this->assign('user', $user);
        return $this->success('');
	}
}
